package com.mojian.controller.article;

import java.util.List;
import java.util.Map;

import com.mojian.entity.SysZb;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import com.mojian.entity.SysTb;
import com.mojian.service.SysTbService;
import com.mojian.common.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;

/**
 * 投标 控制器
 */
@RestController
@RequestMapping("/sys/sysTb")
@RequiredArgsConstructor
@Api(tags = "投标管理")
public class SysTbController {

    private final SysTbService sysTbService;

    @GetMapping("/listAll")
    @ApiOperation(value = "获取投标列表")
    public Result<IPage<SysTb>> listAll(SysTb sysTb) {
        return Result.success(sysTbService.selectPage(sysTb));
    }

    @GetMapping("/listUser")
    @ApiOperation(value = "获取当前用户历史投标列表")
    public Result<IPage<SysTb>> listUser(SysTb sysTb) {
        return Result.success(sysTbService.selectUserTbList(sysTb));
    }

    @GetMapping("/list")
    @ApiOperation(value = "根据招标ID获取投标列表")
    public Result<List<Map<String, Object>>> list(@RequestParam String zbid) {
        return Result.success(sysTbService.selectCustomList(zbid));
    }

    @GetMapping("/listZb")
    @ApiOperation(value = "中标数据")
    public Result<List<Map<String, Object>>> listZb() {
        return Result.success(sysTbService.selectTbUserInfo());
    }

    @GetMapping("/YBPSJ")
    @ApiOperation(value = "仪表盘数据")
    public Result<List<Map<String, Object>>> YBPSJ() {
        return Result.success(sysTbService.selectYBPSJ());
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "获取投标详情")
    public Result<SysTb> getInfo(@PathVariable("id") Long id) {
        return Result.success(sysTbService.getById(id));
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加投标")
    public Result<Object> add(@RequestBody SysTb sysTb) {
        return Result.success(sysTbService.insert(sysTb));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改投标")
    public Result<Object> edit(@RequestBody SysTb sysTb) {
        return Result.success(sysTbService.update(sysTb));
    }

    @PutMapping("/updateDb")
    @ApiOperation(value = "定标")
    public Result<Object> editDb(@RequestBody SysTb sysTb) {
        return Result.success(sysTbService.updateDb(sysTb));
    }

    @DeleteMapping("/delete/{ids}")
    @ApiOperation(value = "删除投标")
    public Result<Object> remove(@PathVariable List<Long> ids) {
        return Result.success(sysTbService.deleteByIds(ids));
    }
}
